package cn.com.b2office.struts2.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import cn.com.b2office.domain.Cart;
import cn.com.b2office.domain.Order;
import cn.com.b2office.service.OrderService;

import com.opensymphony.xwork2.ActionSupport;

public class ListCartItemAction extends ActionSupport implements SessionAware {

	private static final long serialVersionUID = 5644469940631016564L;

	private Map session = null;

	private OrderService orderService = null;

	private List<Order> orders = null;

	public String execute() throws Exception {
		Cart cart = (Cart) session.get("cart");
		if (cart == null)
			return "empty";
		orders = orderService.buildOrders(cart);
		return SUCCESS;

	}

	public void setSession(Map session) {
		this.session = session;
	}

	public void setOrderService(OrderService orderService) {
		this.orderService = orderService;
	}

	public List<Order> getOrders() {
		return orders;
	}

}
